package com.cam.generator.service;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.StringWriter;
import java.nio.charset.Charset;

@Service
@Transactional
public class VelocityTestService {

    public String renderTestTemplate() {
        VelocityContext velocityContext = new VelocityContext();
        velocityContext.put("testString", "#{");
        StringWriter stringWriter = new StringWriter();
        Template template = Velocity.getTemplate("vms/test/velocityTest.vm", Charset.defaultCharset().name());
        template.merge(velocityContext, stringWriter);
        return stringWriter.toString();
    }
}
